<template>
    <view>


        <daya-clone-navbar :prop_clone_navbar="clone_navbar" :prop_is_ipx="is_ipx"/>

        <view class="main">
            <view class="banner" v-if="toplb.length != 0">
                <view class="swiper-container">
                    <swiper
                        autoplay="auto"
                        :circular="true"
                        class="swiper"
                        duration="500"
                        :indicatorActiveColor="color"
                        indicatorColor="white"
                        :indicatorDots="true"
                        interval="5000"
                    >
                        <swiper-item @tap="tzweb" :data-index="index" v-for="(item, index) in toplb" :key="item.unique">
                            <image
                                @tap="jumps"
                                class="img"
                                :data-appid="item.appid"
                                :data-id="item.id"
                                :data-name="item.title"
                                :data-src="item.src"
                                :data-type="item.item"
                                :data-wb_src="item.src2"
                                mode="aspectFill"
                                :src="item.logo"
                            ></image>
                        </swiper-item>
                    </swiper>
                </view>
            </view>
            <view class="no-data-tip zwdd" v-if="order_list.length == 0 && mygd">
                <image mode="aspectFit" src="https://yunkeososyunchuc.bc8t.cn/ymq_canyino2o/static/list.png"></image>
                <view>暂无相关数据~</view>
            </view>
            <view @tap="tzsjxq" class="mainlist" :data-sjid="item.id" v-if="item.aa1 != NaN" v-for="(item, index) in order_list" :key="index">
                <view class="sjlb flex-row">
                    <view class="sjleft flex-grow-0">
                        <image class="sjleftimg" mode="aspectFill" :src="item.logo"></image>
                        <view class="xzhiding" v-if="item.is_brand == '1'">品牌</view>
                    </view>
                    <view class="sjright flex-grow-1 flex-col">
                        <view class="sjright1 flex-row flex-y-center">
                            <view class="sjright1-l gobyndsingle">{{ item.name }}</view>
                        </view>
                        <view class="sjright2 flex-bet flex-y-center">
                            <view class="flex-row flex-grow-1 flex-y-center">
                                <view class="pingjia_fenshu3">
                                    <view class="kximg">
                                        <image src="https://yunkeososyunchuc.bc8t.cn/ymq_canyino2o/static/i-star.png"></image>
                                    </view>
                                    <view class="sximg" :style="'width: ' + item.sales * 20 + '%'">
                                        <image src="https://yunkeososyunchuc.bc8t.cn/ymq_canyino2o/static/i-stars.png"></image>
                                    </view>
                                </view>
                                <view class="pingfen">{{ item.sales }}</view>
                                <view class="recommed_midel">月售{{ item.score }}单</view>
                            </view>
                            <view class="sjright2-r flex-grow-0 flex-row flex-y-center">
                                <view class="sjright2-r1">{{ item.ps_mode }}</view>
                                <view class="sjright2-r2">准时达</view>
                            </view>
                        </view>
                        <view class="sjright3 flex-bet flex-y-center">
                            <view class="flex-row flex-y-center">
                                <view class="sjright3text" style="padding-left: 0">起送￥{{ item.start_at }}</view>
                                <view class="sjright3text" style="border-right: 0">配送￥{{ item.ps_money }}起</view>
                            </view>
                            <view class="flex-row flex-y-center">
                                <view class="sjright3text">{{ item.aa }}</view>
                                <view class="sjright3text" style="border-right: 0; padding-right: 0">{{ item.ps_time }}</view>
                            </view>
                        </view>
                        <view class="sjright4" v-if="item.mj.length > 0 && item.xyh_open == '1'">
                            <view class="sjright4-l flex-grow-1" v-if="item.mj.length > 0">
                                <view class="flex-row">
                                    <view class="mj">减</view>
                                    <view class="gobyndsingle">
                                        <text v-for="(i, index1) in item.mj" :key="index1">满{{ i.full }}减{{ i.reduction }},</text>
                                    </view>
                                </view>
                                <view class="flex-row" v-if="item.xyh_open == '1'">
                                    <view class="xyh">新</view>
                                    <view class="gobyndsingle">新用户下单立减{{ item.xyh_money }}元</view>
                                </view>
                            </view>
                            <view class="sjright4-r flex-grow-0">
                                <image :class="'sjright4-rimg ' + (item.open ? 'show' : 'close')" src="https://yunkeososyunchuc.bc8t.cn/ymq_canyino2o/static/down.png"></image>
                            </view>
                        </view>
                    </view>
                </view>

                <view class="xsqg">
                    <scroll-view class="xsqg-sv" :scrollX="true">
                        <view class="xsqg-view" v-for="(gitem, index1) in item.hot" :key="index1">
                            <image mode="aspectFit" :src="gitem.logo"></image>

                            <view class="gobyndsingle">{{ gitem.name }}</view>

                            <view class="gobyndsingle">
                                <text>￥{{ gitem.money }}</text>
                                <text>￥{{ gitem.money2 }}</text>
                            </view>
                        </view>
                    </scroll-view>
                </view>
            </view>
            <view class="jzz" v-if="!mygd">
                <image class="Rotation" src="https://yunkeososyunchuc.bc8t.cn/ymq_canyino2o/static/jzz.png"></image>
                <view>加载中...</view>
            </view>
            <view class="jzwb" v-if="mygd">
                <view class="hx"></view>
                <view class="wz">加载完毕</view>
                <view class="hx"></view>
            </view>
        </view>
    </view>
</template>

<script>
import cardlist from '@/ymq_canyino2o/dist/cardlist/index';
import gettel from '@/ymq_canyino2o/dist/gettel/index';
var qqmapsdk;
var _typeof =
    'function' == typeof Symbol && 'symbol' == typeof Symbol.iterator
        ? function (t) {
              return typeof t;
          }
        : function (t) {
              return t && 'function' == typeof Symbol && t.constructor === Symbol && t !== Symbol.prototype ? 'symbol' : typeof t;
          };
var app = getApp();
var QQMapWX = require('../../utils/qqmap-wx-jssdk.js');
export default {
    components: {
        cardlist,
        gettel
    },
    data() {
        return {
            navbar: [
                {
                    name: '全部',
                    id: ''
                }
            ],

            selectedindex: 0,

            params: {
                nopsf: 2, //是否有配送费
                nostart: 2, //是否有起送费
                yhhd: ''
            },

            status: 1,
            pagenum: 1,
            order_list: [],
            storelist: [],
            mygd: false,
            jzgd: true,
            store_id: '',
            toplb: '',
            mask1Hidden: false,
            toView: '',


            color: '',
            NaN: '',

            i: {
                full: '',
                reduction: ''
            },

            gitem: {
                logo: '',
                name: '',
                money: '',
                money2: ''
            }
        };
    },
    onLoad: function (t) {
        app.globalData.setNavigationBarColor(this);
        this.appPageOnLoad(app);
        var that = this;
        var a = t.storeid;
        console.log(t, a, 'undefined', getApp().globalData.xtxx);
        uni.setNavigationBarTitle({
            title: t.title || '精选好店'
        });
        that.setData({
            store_id: a
        });
        qqmapsdk = new QQMapWX({
            key: getApp().globalData.xtxx.map_key
        });
        that.dwreLoad();
        app.globalData.util.request({
            url: 'entry/wxapp/ad',
            cachetime: '0',
            success: function (t) {
                console.log(t);
                for (var a = [], e = 0; e < t.data.length; e++) {
                    if ('10' == t.data[e].type) {
                        a.push(t.data[e]);
                    }
                }
                console.log(a, [], []);
                that.setData({
                    toplb: a
                });
            }
        });
    },
    onReady: function () {},
    onShow: function () {},
    onHide: function () {},
    onUnload: function () {},
    onPullDownRefresh: function () {},
    onReachBottom: function () {
        console.log('上拉加载', this.pagenum);
        if (!this.mygd && this.jzgd) {
            this.setData({
                jzgd: false
            });
            this.reLoad();
        }
    },
    methods: {
        dwreLoad: function () {
            var that = this;
            var o = this.params;
            uni.getLocation({
                type: 'wgs84',
                success: function (t) {
                    var a = t.latitude;
                    var e = t.longitude;
                    o.lat = a;
                    o.lng = e;
                    that.setData({
                        params: o
                    });
                    that.reLoad();
                }
            });
        },

        onOverallTag: function (t) {
            console.log(t);
            this.setData({
                mask1Hidden: false
            });
        },

        mask1Cancel: function () {
            this.setData({
                mask1Hidden: true
            });
        },

        selectednavbar: function (t) {
            console.log(t);
            this.setData({
                pagenum: 1,
                order_list: [],
                storelist: [],
                mygd: false,
                jzgd: true,
                selectedindex: t.currentTarget.dataset.index,
                toView: 'a' + (t.currentTarget.dataset.index - 1),
                status: Number(t.currentTarget.dataset.index) + 1
            });
            this.reLoad();
        },

        reLoad: function () {
            var t;
            var that = this;
            var a = this.status || 1;
            var e = this.store_id || '';
            this.store_id;
            that.params.page = that.pagenum;
            that.params.pagesize = 5;
            if (1 == a) {
                t = '';
            } else {
                t = that.navbar[a - 1].id;
            }
            console.log(a, t, e, that.params);
            app.globalData.util.request({
                url: 'entry/wxapp/SelectStoreList',
                cachetime: '0',
                data: that.params,
                success: function (t) {
                    console.log('分页返回的列表数据', t.data);
                    for (var a = 0; a < t.data.length; a++) {
                        if ('0.0' == t.data[a].sales) {
                            t.data[a].sales = '5.0';
                        }
                        var e = parseFloat(t.data[a].juli);
                        console.log(e);
                        console.log();
                        if (e < 1000) {
                            t.data[a].aa = e + 'm';
                        } else {
                            t.data[a].aa = (e / 1000).toFixed(2) + 'km';
                        }
                        t.data[a].aa1 = e;
                    }
                    if (t.data.length < 5) {
                        that.setData({
                            mygd: true,
                            jzgd: true
                        });
                    } else {
                        that.setData({
                            jzgd: true,
                            pagenum: that.pagenum + 1
                        });
                    }
                    var s = that.storelist;
                    s = (function (t) {
                        for (var a = [], e = 0; e < t.length; e++) {
                            if (-1 == a.indexOf(t[e])) {
                                a.push(t[e]);
                            }
                        }
                        return a;
                    })((s = s.concat(t.data)));
                    that.setData({
                        order_list: s,
                        storelist: s
                    });
                    console.log(s);
                }
            });
        },

        tzsjxq: function (t) {
            console.log(t.currentTarget.dataset, getApp().globalData.xtxx);
            if (1 == t.currentTarget.dataset.type) {
                getApp().globalData.sjid = t.currentTarget.dataset.sjid;
                uni.navigateTo({
                    url: '/ymq_canyino2o/pages/seller/index'
                });
            } else {
                if ('1' == getApp().globalData.xtxx.is_tzms) {
                    getApp().globalData.sjid = t.currentTarget.dataset.sjid;
                    uni.navigateTo({
                        url: '/ymq_canyino2o/pages/seller/index'
                    });
                } else {
                    uni.navigateTo({
                        url: '/ymq_canyino2o/pages/takeout/takeoutindex?storeid=' + t.currentTarget.dataset.sjid
                    });
                }
            }
        },

        tzweb() {
            console.log('占位：函数 tzweb 未声明');
        },

        jumps() {
            console.log('占位：函数 jumps 未声明');
        }
    }
};
</script>
<style>
@import './sgstore.css';
</style>
